import org.apache.spark.sql.{DataFrame, SparkSession}

object ReadJson {
  def main(args: Array[String]): Unit = {

    val spark: SparkSession = SparkSession.builder().appName(this.getClass.getName)
      .master("local[*]")
      .getOrCreate()

    val frame: DataFrame = spark.read
      .json("file:///C:\\Users\\Xianglei\\Desktop\\andor\\sojson.com.json")
    frame.show(10,false)
    val frame1: DataFrame = spark.sql(
      """select re.regionkey, re.NAME,avg(c.acctbal)
        |from customer c
        |join
        |nation n
        |on c.nationkey = n.nationkey
        |join
        |region re
        |on n.regionkey = re.regionkey
        |group by re.regionkey;""".stripMargin)
    frame1.write
//      .jdbc()







    spark.stop()
  }
}
